﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Reflection;
using System.Xml.Linq;

namespace BulldogCMS.Core.Storage.DataTypes
{
    public abstract class BaseDataType
    {
        public string Name
        {
            get;
            set;
        }

        public static BaseDataType Instantiate(Type type)
        {
            ConstructorInfo constuctorInfo = type.GetConstructor(System.Type.EmptyTypes);
            if (constuctorInfo != null)
            {
                return constuctorInfo.Invoke(new object[] {}) as BaseDataType;
            }
            return null;
        }

        public abstract XElement ToXElement();

        public abstract void LoadFromXElement(XElement el);

        public abstract XElement GetMetadata();

        public abstract dynamic ToDynamicObject();

        public abstract void LoadFromDynamicObject(dynamic obj);

    }
}